home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / slix0987.zip / RAW100.ZIP / SEE8-100.BAS < prev   
BASIC Source File  |  1996-05-20  |  3KB  |  89 lines

  1. 'SEE8-100.BAS
  2. '
  3. '8 bit RAW file viewer 1.00 -- written by Lloyd Chang
  4. '
  5. 'purpose: Displays a 8 bit RAW file in 320x200x256
  6. '         mode (SCREEN 13)
  7. '        
  8. 'note: The user of this program has to know the
  9. '      horizontal size of the 8 bit RAW file beforehand.
  10. '      The horizontal size can be designated by
  11. '      manipulating the RAWWidth% integer.
  12. '
  13. 'note: An error might occur when this program is
  14. '      used in the QuickBASIC Environment.
  15. '      Try using RAW100.EXE or recompiling RAW100.BAS
  16. '
  17. 'note: Discoloration may occur.  This is due to the
  18. '      available of colors in a 256 color RGB palette,
  19. '      although the problem is caused by RAW100.BAS,
  20. '      not SEE8-100.BAS, since dithering is not supported
  21. '      in RAW100.BAS
  22. '
  23. '      However, a 256 color RGB palette is useful since
  24. '      it replaces constant palette switching, which is
  25. '      a hassle when writing programs such as games.
  26. '
  27. '      But, if the programmer is writing a picture
  28. '      viewer, he or she should switch palettes in
  29. '      between different picture (by loading the
  30. '      corresponding palette of the graphic file).
  31. '
  32. 'note: An error might occur when this program is
  33. '      used in the QuickBASIC Environment.
  34. '      Try reducing BufferSize%.
  35. '
  36. 'files that should accompany this program: ASTRNAUT.24
  37. '                                          ASTRNAUT.8
  38. '                                          ASTRNAUT.JPG
  39. '                                          BRUN45.EXE
  40. '                                          FILE_ID.DIZ
  41. '                                          INDEX.TXT
  42. '                                          RAW100.BAS
  43. '                                          RAW100.EXE
  44. '                                          RGB.PAL
  45. '                                          RGB100.BAS
  46. '
  47. DECLARE SUB RGBLoad ()
  48. SCREEN 13
  49. RGBLoad
  50. DEFINT A-Z
  51. RAWWidth% = 320
  52. BufferSize% = 32766
  53. Buffer$ = SPACE$(BufferSize%)
  54. OPEN "ASTRNAUT.8" FOR BINARY AS #1
  55. DO
  56.   GET #1, , Buffer$
  57.   FOR Count% = 1 TO BufferSize%
  58.     Counter& = (Carrier& * BufferSize%) + Count%
  59.     SELECT CASE Counter&
  60.       CASE IS > LOF(1)
  61.         EXIT FOR
  62.     END SELECT
  63.     Y% = Counter& \ RAWWidth%
  64.     X% = (Counter& - 1) MOD RAWWidth%
  65.     PSET (X%, Y%), ASC(MID$(Buffer$, Count%, 1))
  66.   NEXT Count%
  67.   Carrier& = Carrier& + 1
  68. LOOP UNTIL EOF(1)
  69. CLOSE #1
  70.  
  71. DEFSNG A-Z
  72. SUB RGBLoad
  73. DEFINT A-Z
  74. RGBFile% = FREEFILE
  75. OPEN "RGB.PAL" FOR BINARY AS #RGBFile%
  76. RGBPalette$ = SPACE$(768)
  77. GET #RGBFile%, , RGBPalette$
  78. CLOSE #RGBFile%
  79. DIM RGBPal(0 TO 255) AS LONG
  80. FOR Count% = 0 TO 255
  81.   Red% = (ASC(MID$(RGBPalette$, ((Count% * 3) + 1), 1)) \ 4)
  82.   Green% = (ASC(MID$(RGBPalette$, ((Count% * 3) + 2), 1)) \ 4)
  83.   Blue% = (ASC(MID$(RGBPalette$, ((Count% * 3) + 3), 1)) \ 4)
  84.   RGBPal(Count%) = (65536 * Blue% + 256 * Green% + Red%)
  85. NEXT Count%
  86. PALETTE USING RGBPal
  87. END SUB
  88.  
  89.